<?php
	$_title='个人主页|我的消息';
	include_once 'head.php';
	$newsc=new news(); //消息类
	//左侧导航
	$my_label='message';
	$smarty->assign('my_label',$my_label);		
	$userc=new user();
	// $user_id=1;


	$table='user_message';
	if($_GET['action']=='del'){
		if($user_id!='' && $user_id!=null){
			$del_id=$_POST['del_id'];
			$arr=array('is_del'=>'del');
			$where=' msg_id='.$del_id.' AND user_id='.$user_id;
			$res=$newsc->message_update($arr,$where);
			// if($res){
			// 	$error=0;
			// }else{
			// 	$error=1;
			// }
			$result=array('error'=>$res);
			echo json_encode($result);
			exit();
		}
	}



	//读取作者个人信息
	if($user_id!='' && $user_id!=null){
		$key='i.*';
		$user=$userc->userInfo($user_id,$key);
		$smarty->assign('user',$user);
	}else{
		header('Location:login.php');
	}	

	$smarty->assign('user',$user);


	//读取系统信息
	$where=' AND l.user_id='.$user_id.' AND l.is_del="undel"';
	$row=$newsc->message_sys($where);
	$page=$row['page'];
 	$row=$row['result'];
 	for ($i=0; $i <count($row) ; $i++) { 
 		@$row[$i]['create_time']=date('Y-m-d H:i:s',$row[$i]['create_time']);
 	}




	$smarty->assign('page',$page);
	$smarty->assign('row',$row);

	//html模板区分
	$html='my_message_sys.html';
	$smarty->display($html);		
?>